Ext.ns('journal.ui');

journal.ui.HtmlEditor = function(config) {

    journal.ui.HtmlEditor.superclass.constructor.call(this, config);
};

Ext.extend(journal.ui.HtmlEditor, Ext.form.HtmlEditor, {

    setReadOnly : function(bool) {
        if (this.el != null) {
            //this.setDesignMode(!bool);
            this.disableItems(bool);
        }
    },

    // private
    applyCommand : function(e) {
        if (e.ctrlKey) {
            var c = e.getCharCode();
            var cmd = null;
            if (c > 0) {
                c = String.fromCharCode(c);
                switch (c) {
                case 'b':
                    cmd = 'bold';
                    break;
                case 'B':
                    cmd = 'bold';
                    break;
                case 'i':
                    cmd = 'italic';
                    break;
                case 'I':
                    cmd = 'italic';
                    break;
                case 'u':
                    cmd = 'underline';
                    break;
                case 'U':
                    cmd = 'underline';
                    break;
                }
                if (cmd) {
                    this.win.focus();
                    this.execCmd(cmd);
                    this.deferFocus();
                    e.preventDefault();
                }
            }
        }
    }
});

Ext.reg('journal.ui.HtmlEditor', journal.ui.HtmlEditor);
